//
//  NSObject+AppInfo.m
//  category
//
//  Created by MAC on 2018/5/5.
//  Copyright © 2018年 MAC. All rights reserved.
//

#import "NSObject+AppInfo.h"

@implementation NSObject (AppInfo)

- (NSString *)ex_version{
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
    return app_Version;
}

- (NSInteger)ex_build{
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"];
    return [app_build integerValue];
}

- (NSString *)ex_identifier{
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString * bundleIdentifier = [infoDictionary objectForKey:@"CFBundleIdentifier"];
    return bundleIdentifier;
}

- (NSString *)ex_currentLanguage{
    NSArray *languages = [NSLocale preferredLanguages];
    NSString *currentLanguage = [languages firstObject];
    return [NSString stringWithString:currentLanguage];
}

@end

@implementation NSObject (AppIcon)

- (NSString *)ex_appIconPath {
    NSString* iconFilename = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIconFile"] ;
    NSString* iconBasename = [iconFilename stringByDeletingPathExtension] ;
    NSString* iconExtension = [iconFilename pathExtension] ;
    return [[NSBundle mainBundle] pathForResource:iconBasename
                                           ofType:iconExtension] ;
}

- (UIImage *)ex_appIcon {
    UIImage*appIcon = [[UIImage alloc] initWithContentsOfFile:[self ex_appIconPath]] ;
    return appIcon;
}
@end
